//数字格式化，处理超过1000的数就会变成1,000
export function getArea(area) {
  return String(area).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
//处理时间格式--- js：年月日
export function time(time) {
  var data = new Date(time);
  //自动拼接
  // return data.toLocaleDateString().replace(/\//g, "-") + " " + data.toTimeString().substr(0, 5)
  //手动拼接
  var y = data.getFullYear();
  var m = data.getMonth() + 1;
  var d = data.getDate();
  return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + data.toTimeString().substr(0, 5);
}

export function formatText(str, size, delimiter) {
  var _size = size || 3,
    _delimiter = delimiter || ',';
  var regText = '\\B(?=(\\w{' + _size + '})+(?!\\w))';
  var reg = new RegExp(regText, 'g');
  return str.replace(reg, _delimiter);
}
